home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / networking / pgpuam / sources / removeserverkey.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  1.6 KB  |  77 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stddef.h> /* needed for offsetof */
  4. #include <string.h>
  5. #include <console.h>
  6. #include <sioux.h>
  7. #include <PLStringFuncs.h>
  8.  
  9. #include "AppleShareRegistry.h"
  10. #include "AppleShareFileServerRegistry.h"
  11.  
  12.  
  13.  
  14. void BuildObjectSpecByShortID(OAMObjectSpec *obj, OAMShortObjectSpec id)
  15. {
  16.     memset(obj, 0, sizeof(OAMObjectSpec));
  17.     obj->specType = kOAMObjectSpecByShortID;
  18.     obj->u.shortID = id;
  19. }
  20.  
  21. void BuildObjectSpecByNameType(OAMObjectSpec *obj, StringPtr name, OAMType type)
  22. {
  23.     short len = 0;
  24.     
  25.     memset(obj, 0, sizeof(OAMObjectSpec));
  26.     obj->specType = kOAMObjectSpecByNameType;
  27.     obj->objectType = type;
  28.     len = *name + 1;
  29.     memcpy(obj->u.name, name, len);
  30. }
  31.  
  32.  
  33. OAMStatus RemoveServerKey(OAMSessionID sessionId)
  34. {
  35.  
  36.     OAMStatus                err = noErr;
  37.     OAMObjectSpec            obj;    
  38.     OAMAttributeDescriptor     attr[2] = {};
  39.     
  40.     unsigned char            key[4096];
  41.         
  42.      memset(&attr, 0, sizeof(attr));
  43.  
  44.     attr[0].attributeSignature             = kOAMMachine;
  45.     attr[0].attributeType                 = 'PGPs';
  46.     attr[0].bufferDescriptor.buffer     =  key;
  47.     attr[0].bufferDescriptor.bufferLen     =  sizeof(key);
  48.       attr[1].attributeSignature = NULL;
  49.  
  50.     memset(&obj, 0, sizeof(OAMObjectSpec));
  51.     
  52.     obj.specType = kOAMObjectSpecByShortID;
  53.     obj.u.shortID = kOAMMachineShortID;
  54.   
  55.       err = OAMDeleteAttribute(sessionId, &obj,  attr, NULL);
  56.       return err;
  57.       
  58. }
  59.  
  60. int main ( void)
  61. {
  62.      OAMStatus         err = noErr;
  63.     OAMSessionID    sessionID = 0;
  64.   
  65.       err = OAMInitialize(1, 0, NULL, NULL);
  66.       
  67.      err = OAMOpenSession(NULL, &sessionID, NULL);
  68.      if (sessionID)
  69.     {
  70.          err = RemoveServerKey( sessionID);
  71.       
  72.         OAMCloseSession(sessionID, NULL);
  73.     }
  74.     err = OAMDeInitialize();
  75.  
  76.      return 0;
  77.   }